import axios from 'axios';

axios.defaults.baseURL = "https://testshool.zzgoodqc.cn/index.php/index/"

export function apiGet(url, params) {
    return new Promise((resolve, reject) => {
        axios.get(url, {
            params: params,
            headers: { "token": sessionStorage.getItem('token') }
        }).then(res => {
            resolve(res.data);
        }).catch(err => {
            reject(err.data)
        })
    });
}

export function apiPost(url, params) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'post',
            url: url,
            data: params,
            headers: { "token": localStorage.getItem("token") }
        }).then(res => {
            resolve(res.data);
        }).catch(err => { reject(err.data) })
    });
}
